/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ac.lib.users;

import static ac.lib.users.permissions.usertype;
import ac.settings.dataModel;
import static ac.settings.dataModel.TABLE_permissions;
import ac.ui.controls.PCLButton;
import ac.ui.utils;

/**
 *
 * @author empcl_000
 */
public class operations implements dataModel {

    public String[] getRow() {

        return db.getRow(TABLE_users, "id='" + ac.settings.sesstionData.userID + "'");

    }

    public String getUserName() {

        return this.getRow()[1];

    }

    public String getUserLang() {

        return this.getRow()[3];

    }

    public String getUserType() {

        return this.getRow()[4];

    }

    public static boolean checkPermissions(java.awt.event.ActionEvent e) {
        boolean r = true;

        return r;
    }

    ac.lib.database.operations db = new ac.lib.database.operations();

    public boolean login(String userName, String password) {
        boolean returnData = false;
        ac.settings.sesstionData.userID = "";

        String[] sqlData = db.getRow(TABLE_users, "`userName`='" + userName + "' and `password`='" + tmp.ac.lib.tools.util.md5(password) + "'");

        if (sqlData[0] != null && !sqlData.equals("null")) {

            returnData = true;
            ac.settings.sesstionData.userID = sqlData[0];
            ac.settings.sesstionData.userType = sqlData[4];
            ac.lib.users.permissions.usertype = sqlData[4];
        }

        return returnData;

    }

}
